﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using Moxiecode.TinyMCE.Web;
using Moxiecode.TinyMCE.Configuration;

namespace Moxiecode.TinyMCE.Settings
{
    [TypeConverter(typeof(GzipSettingsConverter))]
    public class GzipSettings
    {
        [DefaultValue(false), NotifyParentProperty(true)]
        public bool Enabled { get; set; }

        [DefaultValue("c:\\temp"), NotifyParentProperty(true)]
        public string CachePath { get; set; }

        [DefaultValue(false), NotifyParentProperty(true)]
        public bool DiskCache { get; set; }

        [DefaultValue(10L), NotifyParentProperty(true)]
        public long ExpiresOffset { get; set; }

        [DefaultValue(false), NotifyParentProperty(true)]
        public bool NoCompression { get; set; }

        public GzipSettings() : this(null) { }

        public GzipSettings(GzipTinyConfigElement gzipSection)
        {
            if (gzipSection == null) gzipSection = new GzipTinyConfigElement();
            Enabled = gzipSection.Enabled;
            CachePath = gzipSection.CachePath;
            DiskCache = gzipSection.DiskCache;
            ExpiresOffset = gzipSection.ExpiresOffset;
            NoCompression = gzipSection.NoCompression;
        }
    }
}
